<template>
  <div class="home">    
      <common-silder :swiperList="swiperList"></common-silder>
      <common-notice-bar></common-notice-bar>
      <common-new-list :newList="newList"></common-new-list>
      <!-- <common-poster></common-poster> -->
      <!-- <common-grid></common-grid> -->
      <common-foot></common-foot>
  </div>
</template>
<script>
import CommonSilder from "@/views/common/Silder";
import CommonNoticeBar from "@/views/common/NoticeBar";
import CommonGrid from "@/views/common/Grid";
import CommonPoster from "@/views/common/Poster";
import CommonNewList from "@/views/common/NewList";
import CommonFoot from "@/views/common/Foot";
import ApiPath from "@/api/ApiPath";

export default {
  name: 'Home',
  components: {
      CommonSilder,
      CommonNoticeBar,
      CommonGrid,
      CommonPoster,
      CommonNewList,
      CommonFoot
  },
  data () {
    return {
        swiperList: "",
        newList: ""
    }
  },
  created() {
    this.$store.state.isNavShow = true;
    // this.$store.commit("setNavDisplay", true);
  },
  beforeRouteEnter(to, from, next) {
    next(vm => {
      vm.$emit("setNav", to.meta.index);
    });
  },
  methods: {
      getHomeInfo(){
        this.$axios.get(ApiPath.getSilder)
        .then(this.getHomeInfoSucc)
      },
      getHomeInfoSucc(res){
          res = res.data;
          if(res){
            this.swiperList = res.swiperList
          }
          console.log("[index] HomeInfo:"+JSON.stringify(res))
      },
      getNewListInfo(){
        this.$axios.get(ApiPath.getNewList)
        .then(this.getNewListInfoSucc)
      },
      getNewListInfoSucc(res){
        res = res.data;
          if(res){
            this.newList = res.newList
          }
          console.log("[index] NewListInfo"+JSON.stringify(res))
      }
  },
  mounted(){
      this.getHomeInfo();
      this.getNewListInfo();
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped="" type="text/css">
h1, h2 {
  font-weight: normal;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}



</style>
